﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinHomework02
{
    public partial class Form1 : Form
    {
        private Timer timer;

        private bool isRunning = false;
        public Form1()
        {
            InitializeComponent();
            InitializeTimer();

        }
        private void InitializeTimer()
        {
            timer = new Timer();
            timer.Interval = 1000;
            timer.Tick += Timer_Click;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (!isRunning)
            {
                timer.Start();
                button1.Text = "停止时间";
                isRunning = true;

            }
            else
            {
                if (timer.Enabled)
                {
                    timer.Stop();
                    button1.Text = "继续时间";
                }
                else
                {
                    timer.Start();
                    button1.Text = "停止时间";
                }





            }
        }

        private void Timer_Click(object sender, EventArgs e)
        {
            label1.Text = DateTime.Now.ToString("HH:mm:ss");
        }

    }
}
